package cn.feichanghao.nutz.quickstart.service;

import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.service.IdNameEntityService;

import cn.feichanghao.nutz.quickstart.auth.model.User;

@IocBean(fields = "dao")
public class UserService extends IdNameEntityService<User> {
	public UserService() {
		super();
	}

	public UserService(Dao dao) {
		super(dao);
	}

	public User login(String email, String password) {
		// Get User
		User user = null;
		try {
			user = this.fetch(Cnd.where("email", "=", email).and(	"password",
																			"=",
																			password));
		}
		catch (Exception e) {}
		return user;
	}
	
	public User create(String email,String password,String desc)
	{
		User user=null;
		try{
			user=this.dao().insert(new User(email,password));
		}
		catch (Exception e) {}
		return user;
	}
}
